package sample.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpUtil {
    public static String getURLString(String url) {
        try {
            HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
            BufferedReader resultBR=new BufferedReader(new InputStreamReader(connection.getInputStream()));

            StringBuilder resultSB=new StringBuilder();
            String curLine;
            while((curLine=resultBR.readLine())!=null){
                resultSB.append(curLine);
            }

            return resultSB.toString();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
